#!/bin/sh
cd `dirname $0`
function doStart()
{
  ps -ef | grep $1 | grep -v grep | grep -v $0
  if [ $? -ne 0 ]
  then
    nohup java -jar $1 1>/dev/null 2>/dev/null 0</dev/null & echo $! > $1.pid
  else
    echo "$1 is runing....."
  fi
}
function doStop()
{
  ps -ef | grep $1 | grep -v grep | grep -v $0
  if [ $? -ne 0 ]
  then
    echo "$1 is not running..."
  else
    pid=`cat $1.pid`
    kill ${pid}
    rm $1.pid
  fi
}
case $1 in
  start)
    doStart $2
  ;;
  stop)
    doStop $2
  ;;
  *)
    echo "param[0] only can be start/stop"
  ;;
esac